package cn.hd01.repository;

import java.util.Date;

import javax.transaction.Transactional;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import cn.hd01.repository.entity.MonthlyTarget;

@Repository
public interface MonthlyTargetRepository extends JpaRepository<MonthlyTarget, Integer> {
	
	Page<MonthlyTarget> findAll(Specification<MonthlyTarget> spec, Pageable pageable);
	
	Page<MonthlyTarget> findAll(Specification<MonthlyTarget> spec);
	
	@Modifying
	@Transactional
	@Query(value="update MonthlyTarget set amount = ?1, targetTime = ?2, update_time = now() where id=?3")
	int updateMonthlyTarget(Double amount, Date targetTime , Integer id);
	
}
